<?php
namespace app\index\controller;

use think\Db;

class Index
{

	function index(){
		$data1=Db::connect('db_config1')->table('eb_sport_combination')->select();//数据源
		for ($i=0;$i<count($data1);$i++){
			$result = [
				'uid' => $data1[$i]['uid'],

			];
			Db::connect('db_config2')->table('eb_sport_combination')->insert($result);
			unset($result);
		}

	}
//    public function index()
//    {
//    	echo 123;
//    	die;
//        $members =Db::connect('db_config1')->table('ims_mc_members')->select();
//        $fans =Db::connect('db_config1')->table('ims_mc_mapping_fans')->select();
//        $ids = [];
//        for ($a=0;$a<count($members);$a++){
//            $member = $members[$a];
//            for ($b=0;$b<count($fans);$b++){
//
//                if ($member['nickname'] === $fans[$b]['nickname'] && $member['uid'] === $fans[$b]['uid'] ){
//                   $wechatId = Db::connect('db_config2')->table('ebl_wechat_user')->insertGetId([
//                     'unionid' =>$fans[$b]['unionid'],
//                    'routine_openid'=>$fans[$b]['openid'],
//                    'nickname'=>$fans[$b]['nickname'],
//                    'headimgurl' =>$member['avatar'],
//                    'sex' =>$member['gender'],
//                    'city' =>$member['residecity'],
//                    'province' =>$member['resideprovince'],
//                    'country' =>$member['nationality'],
//                    'add_time' =>$fans[$b]['followtime'],
//                   ]);
//
//                   $ids[] = Db::connect('db_config2')->table('ebl_system_member')->insertGetId([
//                       'wx_id'=>$wechatId,
//                       'pid'=>0,
//                       'username'=>$member['mobile'],
//                       'nickname'=>$fans[$b]['nickname'],
//                       'password'=>$member['password'],
//                       'salt'=>$member['salt'],
//                       'email'=>$member['email'],
//                       'mobile'=>$member['mobile'],
//                       'avatar'=>$member['avatar'],
//                       'level'=>1,
//                       'gender'=>$member['gender'],
//                       'money'=>$member['credit1'],
//                       'score'=>$member['credit2'],
//                       'createtime'=>$member['createtime'],
//                       'jointime'=>$member['createtime'],
//                       'token'=>self::uuid()
//                   ]);
//                }
//            }
//        }
//        return $ids;
//    }
    public function uuid()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }

    public function hello($name = 'ThinkPHP5')
    {
        return 'hello,' . $name;
    }

    public function test(){
    	echo 123;
    	die;
       $data =  Db::name('system_member')->select();
       return $data;
    }
}
